package com.ljh.onlinetest.listener;

import com.ljh.onlinetest.domain.User;
import com.ljh.onlinetest.domain.UserEventLog;
import com.ljh.onlinetest.event.UserEvent;
import com.ljh.onlinetest.service.UserEventLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @author ljh
 * @ClassName UserLogListener.java
 * @createTime 2021年12月30日
 */
@Component
public class UserLogListener implements ApplicationListener<UserEvent>{

    private final UserEventLogService userEventLogService;

    @Autowired
    public UserLogListener(UserEventLogService userEventLogService) {
        this.userEventLogService = userEventLogService;
    }

    @Override
    public void onApplicationEvent(UserEvent userEvent) {
        userEventLogService.insertByFilter(userEvent.getUserEventLog());
    }
}
